<template>
    <div>
        <van-nav-bar title="分类" left-text="返回" left-arrow @click-left="onClickLeft" />
        <van-row>
            <van-col span="6">
                <van-sidebar v-model="active">
                    <van-sidebar-item v-for="key in categoriesdata" :title="key.cat_name" />
                </van-sidebar>
            </van-col>

            <van-col span="18">
                <div v-for="items in categoriesdata[active]?.children">
                    <h3>{{ items.cat_name }}</h3>
                    <router-link :to="'/lb/' + cat_name">
                        <van-grid :column-num="3">
                            <van-grid-item v-for="item2 in items.children" :key="value" :icon="item2.cat_icon"
                                :text="item2.cat_name" style="" />
                        </van-grid>
                    </router-link>
                </div>
            </van-col>
        </van-row>
    </div>
</template>

<script setup>
import { ref } from 'vue';
import { categoriesApi } from '@/api/api'
import { useRouter } from 'vue-router';
const router=new useRouter()
const onClickLeft=()=>{
    router.push('/')
}
const categoriesdata = ref([])
const active = ref(0)
categoriesApi().then((res) => {
    console.log('分类', res);

    categoriesdata.value = res.data.message
})
</script>

<style lang="scss" scoped></style>